/*
 * HibernateUtility.java
 *
 * Created on 21 de Março de 2007, 11:02
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package br.ufal.ic.fracao.dao;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;

/**
 *
 * @author guilherme
 */
public class HibernateUtility {
    
    private static SessionFactory sessionFactory;
    
    static {
        try {
            Configuration cfg =  new Configuration().configure();
            sessionFactory = cfg.buildSessionFactory();
            /*SchemaExport schemaExport = new SchemaExport(cfg);
            schemaExport.create(false, true);*/
        } catch (Exception e) { 
            e.printStackTrace();
            sessionFactory = null;
        }
    }
    
    public static Session getSession() {
        return sessionFactory.openSession();
    }    
    
    public static void main(String[] args) {
        Session session = HibernateUtility.getSession();
    }
}
